package com.tengju.bff.interfaces.app.withdraw.assembler;

import com.tengju.bff.interfaces.app.withdraw.vo.BindStatusVO;
import com.tengju.settlement.domain.model.depository.AccountStatus;
import com.tengju.settlement.domain.model.depository.DepositoryAccount;
import com.tengju.settlement.domain.model.depository.DepositoryBankCard;

import java.util.Optional;

public class DepositoryAssembler {

    public static BindStatusVO toBindStatusVO(DepositoryAccount depositoryAccount, DepositoryBankCard successBankCard, Boolean abmOpened, Boolean canImport, String abmJumpUrl, String abmDownloadUrl, Boolean hitWhiteList) {

        return new BindStatusVO(
                Optional.ofNullable(depositoryAccount).map(DepositoryAccount::getStatus)
                        .map(AccountStatus::getVal).orElse(AccountStatus.LOGICAL_CANCEL.getVal()),
                Optional.ofNullable(successBankCard).map(DepositoryBankCard::last4CardNo).orElse(""),
                abmOpened, canImport, abmJumpUrl, abmDownloadUrl, hitWhiteList
        );

    }

}
